# 姓名:刘豹
#  开发时间: 2021/5/21 13:31
from feature import features
from sklearn.svm import SVC
import numpy as np
import pickle
# X_train=features('test2.jpg')
# y_train=np.array([0,0,0,1,1,0,1,0,1,1,1,1,1,1,1,0,0,0,0,1,1,0,1,1,0,1,0,0,0,1,1,1,0,0,0,0,1,0
#                   ,1,1,1,0,1,1,1,1,1,0,1,0,0,1,1,0,0,0,0,1,0,0,0,0,1,0,1,0,0,0,0,1,0,1,0,1,0,1
#                   ,0,0,0,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,0,0,1
#                   ,0,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,1,0,0,1,0,1,1,0,1,1,0,1,0,1,0,1,0,1,0
#                   ,1,1,1,0,1,0,1,1,1,0,0,0,1,1,1,0,1,0,1,0,1,1,1,0,1,0,1,1,1,1,1,1,1,1,0,1,1,0,0,0,1
#                   ,1,0,0,1,0,0,1,0,0,1,1,1,0,0,1,1,1,1,1,0,1,1,0,1,1,0,1,1,1,0,1])
#
# min_on_training=X_train.min(axis=0)
# range_on_training=(X_train-min_on_training).max(axis=0)
# X_train_scaled=(X_train-min_on_training)/range_on_training
# model=SVC(C=0.5,gamma=1)
# model.fit(X_train_scaled,y_train)
#
# f = open('F:/python project/Insect recognition/moudle2/train_data.pkl', 'wb')
# pickle.dump(model, f)
# f.close()
# X_test=features('test3.jpg')
# X_test_scaled=(X_test-min_on_training)/range_on_training
# y_test=np.array([1,1,0,1,0,1,1,1,0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,0,1,0,1,1,0,1,0,1,1
#                  ,0,1,1,0,0,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1
#                  ,1,1,1,0,1,1,0,1,1,1,1,1,1,1,1,0,1,0,0,1,1,1,1,1,1,1,1
#                  ,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1])
X_train=np.loadtxt('D:\python\workspace\insects_detection\chas_data\\test2.txt')
min_on_training=X_train.min(axis=0)
range_on_training=(X_train-min_on_training).max(axis=0)
X_train_scaled=(X_train-min_on_training)/range_on_training
with open('D:\python\workspace\insects_detection\\trainning_models\\train_data_13.pkl', 'rb') as model_file:
    model = pickle.load(model_file)
result=model.predict(X_train_scaled)
print(sum(result==1))
# print(model.score(X_train_scaled,y_train))
# print(model.score(X_test_scaled,y_test))





